package com.kyhd.audio.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kyhd.audio.redis.CodeRedis;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class RedisService {
	
	@Autowired
	CodeRedis codeRedis;

	//String
	public void setKey(String key, String value){
		log.info("redis set key:{},value:{}",key, value);
		this.codeRedis.setKey(key, value);
	}
	
	public void setKeyBySecond(String key, String value, long timeout) {
		log.info("redis set key:{},value:{},timeoutSecond",key, value, timeout);
		this.codeRedis.setKeyBySecond(key, value, timeout);
	}
	
	public void setKeyByMinutes(String key, String value, long timeout) {
		log.info("redis set key:{},value:{},timeoutMinutes:{}",key, value, timeout);
		this.codeRedis.setKeyByMinutes(key, value, timeout);
	}
	
	
	public void setKeyByHour(String key, String value, long timeout) {
		log.info("redis set key:{},value:{},setKeyByHour:{}",key, value, timeout);
		this.codeRedis.setKeyByHour(key, value, timeout);
	}

	public void setKeyByDay(String key, String value, long timeout) {
		log.info("redis set key:{},value:{},timeoutDay:{}",key, value, timeout);
		this.codeRedis.setKeyByDay(key, value, timeout);
	}
	
	public Set<String> getAllKeys(String prestr){
		
		return this.codeRedis.getAll(prestr);
	}
	
	public Object getValue(String key) {
		
		return 	this.codeRedis.getValue(key);
	}

	public void deleteKey(String key) {
		
		this.codeRedis.deleteKey(key);
	}
	
	//List
	public void putList(String key,Object[] args) {
		this.codeRedis.putList(key, args);
	}
	
	public void putListByDirection(String key, Object value, boolean direction) {
		this.codeRedis.putListByDirection(key, value, direction);
	}
	
	public void putListByIndex(String key, int index, String newValue) {
		this.codeRedis.putListByIndex(key, index, newValue);
	}
	
	public void deleteListByNum(String key, int num, String value) {
		this.codeRedis.deleteListByNum(key, num, value);
	}
	
	public List<Object> getList(String key) {
		return this.codeRedis.getList(key);
	}
	
	//Set
	public void putSet(String key,Object[] args) {
		this.codeRedis.putSet(key, args);
	}
	
	public void putSetOne(String key,Object arg) {
		this.codeRedis.putSetOne(key, arg);
	}
	
	public boolean isSetMember(String key,Object arg) {
		return this.codeRedis.isSetMember(key, arg);
	}
	
	public Set<Object> getSet(String key) {
		return this.codeRedis.getSet(key);
	}
	
	public long getSetSize(String key) {
		return this.codeRedis.getSetSize(key);
	}
	
	//哈希 Map
	public void putMap(String key,Map<String,String> map) {
		this.codeRedis.putMap(key, map);
	}
	public void putMapObj(String key,Map<Object,Object> map) {
		this.codeRedis.putMapObj(key, map);
	}
	public void putMapOne(String key, String mapKey, String value) {
		this.codeRedis.putMapOne(key, mapKey, value);
	}
	public Map<Object, Object> getMapAll(String key) {
		return this.codeRedis.getMapAll(key);
	}	
	
	//发布消息
	public void sendMsg(String topic, String msg) {
		this.codeRedis.sendMsg(topic, msg);
	}
}
